<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="author" content="phpok.com" />
	<meta http-equiv="expires" content="wed, 26 feb 1997 08:21:57 gmt"> 
	<title></title>
	<link rel="stylesheet" type="text/css" href="static/bootstrap/{#css#}/bootstrap.css" />
	<link rel="stylesheet" type="text/css" href="static/fontawesome/{#css#}/font-awesome.min.css" />
	<link href="{#css#}/css.php?file=artdialog.css,smartmenu.css" rel="stylesheet" type="text/css" />
	<style type="text/css">
	ul.layout{list-style:none;margin:0;padding:0;}
	ul.layout li{float:left;margin-right:10px;line-height:24px;margin-bottom:3px;}
	ul.layout li label{vertical-align:middle;}
	ul.layout li label input{margin-top:-1px;vertical-align:middle;}
	ul.layout:after{clear:both;content:'.';display:block;visibility:hidden;height:0;overflow:hidden;}
	</style>
	{func phpok_head_css}
	<script type="text/javascript" src="{url ctrl=js ext=jquery.artdialog.js,jquery.smartmenu.js /}"></script>
	{func phpok_head_js}
	<!-- plugin head -->
	<script type="text/javascript">
	var input_id = "#{$id}";
	var multi = {$multi ? "1" : "0"};
	var obj = $.dialog.opener;
	function show_list()
	{
		cid = $.dialog.data('phpok_user_{$id}');
		if(cid == "undefined" || cid == "0" || cid == ""){
			return false;
		}
		$("li[name=list]").show();
		var url = get_url("inp","","type=user&content="+$.str.encode(cid));
		$.phpok.json(url,function(data){
			if(data.status){
				var lst = data.info;
				var c = "";
				for(var i in lst){
					c += '<li id="user_{$id}_'+lst[i]['id']+'">';
					c += '<div class="btn-group">';
					c += '<input type="button" value="'+lst[i]['user']+'" class="btn btn-primary btn-sm" />';
					c += '<input type="button" value="×" title="删除用户：'+lst[i]['user']+'" onclick="delete_input(\''+lst[i]['id']+'\')" class="btn btn-sm btn-danger" /></div>';
					c += '</li>';
					$("#user_"+lst[i]['id']).hide();
				}
				$("#selected_list").html(c).show();
				$.dialog.data("phpok_user_{$id}",cid);
				return true;
			}
			$("#selected_list").hide();
			$.dialog.removeData("phpok_user_{$id}");
		});
	}
	function add_input(val)
	{
		if(multi){
			var old_c = $.dialog.data('phpok_user_{$id}');
			var c = (old_c && old_c != 'undefined') ? old_c+","+val : val;
			var lst = c.split(",");
			lst = $.unique(lst);
			$.dialog.data('phpok_user_{$id}',lst.join(","));
			show_list();
		}else{
			obj.$("#{$id}").val(val);
			obj.action_{$id}_show();
			$.dialog.removeData("phpok_user_{$id}");
			$.dialog.close();
		}
	}
	function delete_input(val)
	{
		if(multi){
			var old_c = $.dialog.data('phpok_user_{$id}');
			if(!old_c){
				return true;
			}
			var lst = old_c.split(",");
			var n_list = new Array();
			var m=0;
			for(var i=0;i<lst.length;i++){
				if(lst[i] != val){
					n_list[m] = lst[i];
					m++;
				}
			}
			if(n_list.length<1){
				$.dialog.removeData("phpok_user_{$id}");
			}else{
				var str = n_list.join(",");
				$.dialog.data("phpok_user_{$id}",str);
			}
		}else{
			$.dialog.removeData("phpok_user_{$id}");
		}
		show_list();
	}
	$(document).ready(function(){
		if(multi == 1){
			var new_c = $.dialog.data("phpok_user_{$id}");
			if(!new_c || new_c == "undefined"){
				new_c = obj.$(input_id).val();
			}
			show_list();
		}
	});
	</script>
</head>
<body>
<div class="card m-1">
	<div class="card-header">
		<form method="post" action="{url ctrl=open func=user id=$id/}">
		<input type="text" class="form-control" name="keywords" id="keywords" value="{$keywords}" style="width:50%;display:inline-block" />
		<input type="submit" value="搜索" class="btn btn-primary" />
		</form>
	</div>
	<!-- if $multi -->
	<div class="card-body">
		
		<div class="list">
			<ul class="layout">
				<li>已选择：</li>
				<div id="selected_list"></div>
				<div class="clear"></div>
			</ul>
		</div>
		
	</div>
	<!-- /if -->
	<table width="100%" class="table">
	<thead>
	<tr>
		<th>ID</th>
		<th width="20px">&nbsp;</th>
		<th width="35px"></th>
		<th class="lft">{lang用户账号}</th>
		<th width="120px">{lang注册时间}</th>
		<th></th>
	</tr>
	</thead>
	<!-- loop from=$rslist key=$key value=$value id=$tmpid -->
	<tr>
		<td align="center">{$value.id}</td>
		<td><span class="status{$value.status}" value="{$value.status}"></span></td>
		<td align="center"><img src="{$value.avatar ? $value.avatar : 'images'.'/user_default.png'}" border="0" width="24px" height="24px" /></td>
		<td align="left">{$value.user}</td>
		<td>{func date 'Y-m-d H:i' $value.regtime}</td>
		<td><input type="button" value="选择" onclick="add_input('{$value.id}')" class="btn btn-primary btn-sm" /></td>
	</tr>
	<!-- /if -->
	</table>
	
	<!-- if $pagelist -->
	<div class="card-footer">
	<nav aria-label="navigation">
		<ul class="pagination justify-content-center">
			<!-- loop from=$pagelist key=$key value=$value id=$tmpid -->
			<li class="page-item{if $value.status} active{/if}" aria-current="page"><a class="page-link" href="{$value.url}">{$value.title}</a></li>
			<!-- /loop -->
		</ul>
	</nav>
	</div>
	<!-- /if -->
</div>
<script type="text/javascript" src="static/bootstrap/{#js#}/bootstrap.bundle.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	var r_menu = [[{
		'text':p_lang('刷新'),
		'func':function(){
			$.phpok.reload();
		}
	}]];
	$(window).smartMenu(r_menu,{
		'name':'smart',
		'textLimit':8
	});
});
</script>
</body>
</html>